package com.interview.b_并发.d_单例模式.b_静态内部类;

/**
 * 属于懒汉模式
 * 外部类加载时 不会直接初始化内部类实例
 * 只有调用时才会被初始化
 */
public class SingleTest {
    public static void main(String[] args) {
        SingleTest instance = SingleTest.getInstance();
    }

    /**
     * 静态 内部类
     */
    private static class SingleTestInstance {
        private static final SingleTest INSTANCE = new SingleTest();
    }

    public static SingleTest getInstance() {
        return SingleTestInstance.INSTANCE;
    }
}
